<template>
  <view>
    <view v-for="items in newsData" :key="items.id" class="news-items">
      <view>{{ items.title }}</view>
      <view class="news-zhaoyao">{{ items.zhaiyao }}</view>
      <view class="news-info">
        <text>发布时间:{{ items.add_time }}</text>
        <text>点击量:{{ items.click }}</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      newsData: [],
    };
  },
  methods: {
    async getNews() {
      const res = await this.$myRequest({
        url: "/api/getnewslist",
      });
      this.newsData = res.data.message;
      console.log(this.newsData);
    },
  },
  onLoad() {
    this.getNews();
  },
};
</script>

<style lang="scss">
.news-items {
  border-bottom: 1px solid black;
  padding: 10rpx;
  .news-zhaoyao {
    margin: 10rpx 0;
    font-size: 20rpx;
  }
  .news-info {
    font-size: 12rpx;
    > text:nth-child(2) {
      margin-left: 50rpx;
    }
  }
}
</style>
